////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 
// 
// This file is part of the Microsoft .NET Micro Framework Porting Kit Code Samples and is unsupported. 
// Copyright (C) Microsoft Corporation. All rights reserved. Use of this sample source code is subject to 
// the terms of the Microsoft license agreement under which you licensed this sample source code. 
// 
// THIS SAMPLE CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 
// INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// 
// 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <tinyhal.h>

// we need this to force inclusion from library at link time
#pragma import(EntryPoint)

extern struct CompressedImage_Header PortBooterLoader_Dat;

typedef unsigned char UINT8;

int LZ77_Decompress( UINT8* inBuf, int inSize, UINT8* outBuf, int outSize );

HAL_DECLARE_NULL_HEAP();

extern "C"
{
void BootEntryLoader()
{
    struct CompressedImage_Header* hdr  = &PortBooterLoader_Dat;
    void*                          data = &hdr[1];

    LZ77_Decompress( (UINT8*)data, hdr->Compressed, (UINT8*)hdr->Destination, hdr->Uncompressed );

    CPU_FlushCaches();

    ((void(*)())hdr->Destination)();
}
}

void ApplicationEntryPoint()  
{
}

